// Package article
// Created by GoLand
// @User: lenora
// @Date: 2024/2/14
// @Time: 15:09

package article

import (
	"context"
	"time"
)

type ArticleDao interface {
	Insert(ctx context.Context, a Articles) (uint64, error)
	UpdateById(ctx context.Context, entity Articles) error
	Sync(ctx context.Context, articles Articles) (uint64, error)
	SyncStatus(ctx context.Context, uid, id uint64, status uint8) error
	GetByAuthor(ctx context.Context, uid uint64, offset, limit int) ([]Articles, error)
	GetById(ctx context.Context, id uint64) (Articles, error)
	ListByOffset(ctx context.Context, start time.Time, offset, size int) ([]Articles, error)
}

type Articles struct {
	//数据表结构
	Id      uint64 `bson:"id,omitempty" gorm:"autoIncrement:true;primaryKey;column:id;type:int(11) unsigned;not null"`
	Title   string `bson:"title,omitempty" gorm:"type=varchar(200)"`
	Content string `bson:"content,omitempty" gorm:"type=BLOB"`
	Creator uint64 `bson:"creator,omitempty" gorm:"index"`
	Status  uint8  `bson:"status,omitempty"`
	Ctime   int64  `bson:"ctime,omitempty"`
	Utime   int64  `bson:"utime,omitempty"`
}

type PublishArticle Articles
